{% load admin_urls %}

{# Note: constants have to be explicitly added to context by the method rendering this template in the ModelAdmin #}

{{ obj.get_state_display }}

{% if obj.pk and obj.state == RUNNING %}
  &nbsp;
  <button class="button" formaction="{% url 'admin:scanners_scannerqueryrule_handle_abort' obj.pk %}">
    Abort
  </button>
{% elif obj.pk and obj.state == NEW %}
  &nbsp;
  <button class="button" formaction="{% url 'admin:scanners_scannerqueryrule_handle_run' obj.pk %}">
    Run
  </button>
{% elif obj.pk and obj.state == COMPLETED and obj.completed %}
    ({{ obj.completed }})
{% endif %}
